<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)</TargetFrameworks>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <EnableAOTAnalyzer>false</EnableAOTAnalyzer>
    <UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
  </PropertyGroup>

  <!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
  <PropertyGroup>
    <TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
    <GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' != 'browser'">SR.SystemRuntimeInteropServicesJavaScript_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
    <FeatureWasmManagedThreads Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmManagedThreads>
    <WasmEnableJsInteropByValue Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableJsInteropByValue)' == '' and '$(FeatureWasmManagedThreads)' == 'true'">true</WasmEnableJsInteropByValue>
    <WasmEnableJsInteropByValue Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(WasmEnableJsInteropByValue)' == ''">false</WasmEnableJsInteropByValue>
    <DefineConstants Condition="'$(FeatureWasmManagedThreads)' == 'true'">$(DefineConstants);FEATURE_WASM_MANAGED_THREADS</DefineConstants>
    <DefineConstants Condition="'$(WasmEnableJsInteropByValue)' == 'true'">$(DefineConstants);ENABLE_JS_INTEROP_BY_VALUE</DefineConstants>
    <EmitCompilerGeneratedFiles Condition="'$(Configuration)' == 'Debug' and '$(TargetPlatformIdentifier)' == 'browser'">true</EmitCompilerGeneratedFiles>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="System.Runtime.InteropServices.JavaScript.SupportedOSPlatform.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'browser'">
    <Compile Include="$(CommonPath)Interop\Browser\Interop.Runtime.cs" Link="System\Runtime\InteropServices\JavaScript\Interop\Interop.Runtime.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Interop\JavaScriptImports.Generated.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Interop\JavaScriptExports.cs" />

    <Compile Include="System\Runtime\InteropServices\JavaScript\JSHost.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSMarshalerType.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSMarshalAsAttribute.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSObject.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSObject.References.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSType.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSFunctionBinding.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSHostImplementation.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSHostImplementation.Types.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSMarshalerArgument.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSException.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSExportAttribute.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSImportAttribute.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\CancelablePromise.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSProxyContext.cs" />

    <Compile Include="System\Runtime\InteropServices\JavaScript\MarshalerType.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.BigInt64.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Char.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Double.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Func.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Single.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Int52.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Int16.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Byte.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Bool.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Task.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.DateTime.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.IntPtr.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Object.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Int32.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.JSObject.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.String.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\Marshaling\JSMarshalerArgument.Exception.cs" />
  </ItemGroup>

  <!-- only include threads support when FeatureWasmManagedThreads is enabled -->
  <ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'browser' and '$(FeatureWasmManagedThreads)' == 'true'">
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSWebWorker.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSSynchronizationContext.cs" />
    <Compile Include="System\Runtime\InteropServices\JavaScript\JSAsyncTaskScheduler.cs" />
  </ItemGroup>
  <ItemGroup Condition="'$(WasmEnableThreads)' == 'true'">
    <ApiCompatSuppressionFile Include="CompatibilitySuppressions.xml;CompatibilitySuppressions.WasmThreads.xml" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="$(CoreLibProject)" />
    <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime\src\System.Runtime.csproj" />
    <ProjectReference Include="$(LibrariesProjectRoot)System.Threading\src\System.Threading.csproj" />
    <ProjectReference Include="$(LibrariesProjectRoot)System.Threading.Channels\src\System.Threading.Channels.csproj" />
    <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
    <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices.JavaScript\gen\JSImportGenerator\JSImportGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
  </ItemGroup>

</Project>
